using System;
using UnityEngine;

namespace 委托和事件
{
    class NewBehaviourScript: MonoBehaviour
    {
        private void Awake()
        {
            Action action = One;
            action += Two;
            action += Three;
            Delegate[] delegates = action.GetInvocationList(); //返回委托挂接的方法，通过他可以控制委托方法执行顺序
            foreach (Action delegateAction in delegates)
            {
                //if (delegateAction == One)
                if (delegateAction == Four)
                {
                    Debug.Log("包含");
                    break;
                }
                else
                {
                    Debug.Log("不包含");
                }
            }
            Console.Read();
        }
        private static void One()
        {
            Console.WriteLine("调用：方法一");
            throw new Exception("Err in one");
        }
        private static void Two()
        {
            Console.WriteLine("调用：方法二");
        }
        private static void Three()
        {
            Console.WriteLine("调用：方法三");
        }

        private static void Four()
        {
            
        }
    }
}